package net.aiion.weave.impl.bytecode.events;

import net.aiion.weave.asm.Label;
import net.aiion.weave.spi.bytecode.BytecodeVisitor;
import net.aiion.weave.spi.bytecode.events.TryCatchBlockBytecodeEvent;

public class TryCatchBlockBytecodeEventImpl extends BytecodeEventImpl implements TryCatchBlockBytecodeEvent
{
    private Label startLabel;
    private Label endLabel;
    private Label handlerLabel;
    private String exceptionName;

    public TryCatchBlockBytecodeEventImpl(final Label aStartLabel, final Label aEndLabel, final Label aHandlerLabel,
        final String aExceptionName)
    {
        startLabel = aStartLabel;
        endLabel = aEndLabel;
        handlerLabel = aHandlerLabel;
        exceptionName = aExceptionName;
    }

    @Override
    public int getType() {
        return TRY_CATCH_BLOCK;
    }

    @Override
    public void setStartLabel(final Label aStartLabel) {
        startLabel = aStartLabel;
    }

    @Override
    public Label getStartLabel() {
        return startLabel;
    }

    @Override
    public void setEndLabel(final Label aEndLabel) {
        endLabel = aEndLabel;
    }

    @Override
    public Label getEndLabel() {
        return endLabel;
    }

    @Override
    public void setHandlerLabel(final Label aHandlerLabel) {
        handlerLabel = aHandlerLabel;
    }

    @Override
    public Label getHandlerLabel() {
        return handlerLabel;
    }

    @Override
    public void setExceptionName(final String aExceptionName) {
        exceptionName = aExceptionName;
    }

    @Override
    public String getExceptionName() {
        return exceptionName;
    }

    @Override
    public BytecodeVisitor acceptBytecodeVisitor(final BytecodeVisitor aBytecodeVisitor) {
        aBytecodeVisitor.asBytecodeMethodVisitor().visitTryCatchBlock(this);
        return aBytecodeVisitor;
    }
}
